<template>
  <div class="singer_contaner">
    <!-- 歌手分类选择 -->
    <div class="singer">
      <div class="selectorItem">
        <div class="title">语种：</div>
        <second-bar
          class="secondNavBar"
          :SecondNavBarData="languageSort"
          @clickSecondBarItem="areaItem"
        ></second-bar>
      </div>
      <div class="selectorItem">
        <div class="title">分类：</div>
        <second-bar
          class="secondNavBar"
          :SecondNavBarData="typeSort"
          @clickSecondBarItem="typeItem"
        ></second-bar>
      </div>
      <div class="selectorItem">
        <div class="title">筛选：</div>
        <second-bar
          class="secondNavBar"
          :SecondNavBarData="initialSort"
          @clickSecondBarItem="initialItem"
        ></second-bar>
      </div>
    </div>
    <!-- 歌手列表 -->
    <div class="listCardContainer">
      <list-card
        :listCardData="singerList"
        @clickListCardItem="onClickListCardItem"
      ></list-card>
    </div>
    <back-top></back-top>
  </div>
</template>

<script>
import BackTop from "../../../components/goTop/BackTop.vue";
import ListCard from "../../../components/listCard/ListCard.vue";
import SecondBar from "../../../components/secondnavbar/SecondBar.vue";
export default {
  name: "MySinger",
  components: {
    SecondBar,
    ListCard,
    BackTop,
  },
  data() {
    return {
      languageSort: [
        { area: -1, name: "全部" },
        { area: 7, name: "华语" },
        { area: 96, name: "欧美" },
        { area: 8, name: "日本" },
        { area: 16, name: "韩国" },
        { area: 0, name: "其它" },
      ],
      typeSort: [
        { type: -1, name: "全部" },
        { type: 1, name: "男歌手" },
        { type: 2, name: "女歌手" },
        { type: 3, name: "乐队" },
      ],
      initialSort: [
        { initial: -1, name: "热门" },
        { initial: "a", name: "A" },
        { initial: "b", name: "B" },
        { initial: "c", name: "C" },
        { initial: "d", name: "D" },
        { initial: "e", name: "E" },
        { initial: "f", name: "F" },
        { initial: "g", name: "G" },
        { initial: "h", name: "H" },
        { initial: "i", name: "I" },
        { initial: "j", name: "J" },
        { initial: "k", name: "K" },
        { initial: "l", name: "L" },
        { initial: "m", name: "M" },
        { initial: "n", name: "N" },
        { initial: "o", name: "O" },
        { initial: "p", name: "P" },
        { initial: "q", name: "Q" },
        { initial: "r", name: "R" },
        { initial: "s", name: "S" },
        { initial: "t", name: "T" },
        { initial: "u", name: "U" },
        { initial: "v", name: "V" },
        { initial: "w", name: "W" },
        { initial: "x", name: "X" },
        { initial: "y", name: "Y" },
        { initial: "z", name: "Z" },
        { initial: 0, name: "#" },
      ],
      area: -1,
      type: -1,
      initial: -1,
      singerList: [],
    };
  },
  created() {
    this.getSingerList();
  },
  methods: {
    // 请求歌手列表
    async getSingerList() {
      const { data: res } = await this.$http("artist/list", {
        params: { type: this.type, area: this.area, initial: this.initial },
      });
      // console.log(res);
      this.singerList = res.artists;
      // console.log(this.singerList);
    },
    // 事件处理
    // 地区
    areaItem(index) {
      // console.log(this.languageSort[index].area);
      this.area = this.languageSort[index].area;
      this.singerList = [];
      this.getSingerList();
    },
    // 分类
    typeItem(index) {
      // console.log(this.typeSort[index].type);
      this.type = this.typeSort[index].type;
      this.singerList = [];
      this.getSingerList();
    },
    // 筛选
    initialItem(index) {
      // console.log(this.initialSort[index].initial);
      this.initial = this.initialSort[index].initial;
      this.singerList = [];
      this.getSingerList();
    },
    // 点击歌手封面回调函数
    onClickListCardItem(id) {
      // console.log(id);
      this.$router.push({ name: "singerdetail", params: { id } });
    },
  },
};
</script>

<style>
.singer {
  width: 90%;
  margin: 0 auto;
}
.selectorItem {
  display: flex;
}
.title {
  font-size: 15px;
  width: 60px;
  line-height: 25px;
  color: #666666;
}
.secondNavBar {
  margin-left: 10px;
  display: flex;
  align-items: center;
  width: 100%;
}
.listCardContainer {
  width: 100%;
  display: flex;
}
</style>